package patterns.command;

import System.Task.Task;

public class SendControlCommand implements MachineCommand {
        private Task task;
        private String controlCommand;

    public SendControlCommand(Task task, String controlCommand) {
            this.task = task;
            this.controlCommand = controlCommand;
        }

        @Override
        public void execute() {
            task.addCommand("发送控制指令: " + controlCommand);
            System.out.println("执行: " + getDescription());
            // 这里实际会通过通信模块发送指令到农机
        }

        @Override
        public void undo() {
            task.addCommand("撤销控制指令: " + controlCommand);
            System.out.println("撤销: " + getDescription());
            // 发送撤销指令到农机
        }

        @Override
        public String getDescription() {
            return "发送控制指令到任务 " + task.getTaskId() + ": " + controlCommand;
        }
    }